package main.java.memento.black_box;

import main.java.memento.black_box.GameRole;
import main.java.memento.black_box.RoleStateCaretaker;

/**
 * 黑箱备忘录
 */
public class Demo {
    public static void main(String[] args) {
        System.out.println("前==========");
        GameRole gameRole = new GameRole();
        gameRole.initState();
        gameRole.stateDisplay();
        //备份状态

       RoleStateCaretaker roleStateCaretaker = new RoleStateCaretaker();
        roleStateCaretaker.setMemento(gameRole.saveState());

        System.out.println("后=============");
        gameRole.fight();
        gameRole.stateDisplay();

        System.out.println("恢复状态=========");
        gameRole.recoverState(roleStateCaretaker.getMemento());
        gameRole.stateDisplay();
    }
}
